﻿package 
{
	import flash.display.Bitmap;
	import flash.display.Loader;
	import flash.events.Event;
	import flash.net.URLRequest;
	import org.papervision3d.materials.BitmapMaterial;
	import org.papervision3d.objects.primitives.Plane;
	import org.papervision3d.objects.primitives.Sphere;
	import org.papervision3d.view.BasicView;
	
	/**
	 * ...
	 * @author qipy
	 */
	public class BasicViewEx extends BasicView 
	{
		private var sphere:Sphere;
		private var plane:Plane;
		
		public function BasicViewEx():void 
		{
			stage.frameRate = 40;
			init();
			//sphere = new Sphere();
			//scene.addChild(sphere);
			//
			
			
			
		}
		
		private function init():void
		{
			var imgLoader:Loader = new Loader();
			imgLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
			imgLoader.load(new URLRequest("assets/mill.jpg"));
		}
		
		private function onComplete(e:Event):void 
		{
			var bitmap:Bitmap = e.target.content as Bitmap;
			var material:BitmapMaterial = new BitmapMaterial(bitmap.bitmapData);
			material.doubleSided = true;
			plane = new Plane(material, 500, 375, 2, 2);
			scene.addChild(plane);
			//trace("plane ");
			startRendering();
		}
		
		override protected function onRenderTick(e:Event=null):void 
		{
			plane.localRotationY += 1;
			super.onRenderTick();
		}
	}
	
}